#!/bin/sh

#============================================================================
# Name        : gen-coid-config
# Author      : Lubos Medovarsky
# Version     : 
# Copyright   : Copyright 2008. MPL/GPL/LGPL
# Description : coid-config generator script, invoked at make install
#============================================================================

while getopts b:l:d:c:i:m: opt; do
	case "$opt" in
	b) BINDIR=${OPTARG#-b}
	   ;;
	l) LIBDIR=$OPTARG
	   ;;
	d) DEVDIR=$OPTARG
	   ;;
	c) CONFDIR=$OPTARG
	   ;;
	i) INCDIR=$OPTARG
	   ;;
	m) MANDIR=$OPTARG
	   ;;
	esac
done
#shift `expr $OPTIND - 1`

if [ "x$BINDIR" = "x" -o "x$LIBDIR" = "x" -o "x$DEVDIR" = "x" \
  -o "x$CONFDIR" = "x" -o "x$INCDIR" = "x" -o "x$MANDIR" = "x" ]; then
	echo "Not all parameters have been specified for $0 -bldicm."
	exit 1
fi

sed \
	-e 's:BINDIR:'$BINDIR':' \
	-e 's:LIBDIR:'$LIBDIR':' \
	-e 's:DEVDIR:'$DEVDIR':' \
	-e 's:INCDIR:'$INCDIR':' \
	-e 's:CONFDIR:'$CONFDIR':' \
	-e 's:MANDIR:'$MANDIR':' <<EOF
#!/bin/sh

# This file has been automatically generated at COID's compile time.
# It serves as a glue between COID and developers' sources

usage() {
	echo "Usage: $0 [--bindir|-b]|[--libdir|-b]|[--devdir|-d]|[--confdir|-c]|[--incdir|-i]|[--mandir|-m]"
	echo "Only one of the parameters can be specified."
	exit 1
}

if [ "\$#" -ne 1 -o "x$1" = "x-h" -o "x$1" = "x--help" ]; then
	usage
fi

case "\$1" in
'--bindir' | '-b')
	echo BINDIR
	;;
'--libdir' | '-l')
	echo LIBDIR
	;;
'--devdir' | '-d')
	echo DEVDIR
	;;
'--confdir' | '-c')
	echo CONFDIR
	;;
'--incdir' | '-i')
	echo INCDIR
	;;
'--mandir' | '-m')
	echo MANDIR
	;;
*)
	usage
esac

exit 0

EOF

exit 0
